package operatation;

import book.Book;
import book.BookList;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-03-23
 * Time: 20:30
 */
public class Find implements IOperatation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请选择你要查找的书：");
        String name = scanner.nextLine();
        int curretSize = bookList.getUsedSize();
        for (int i = 0; i < curretSize ; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("找到了");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书");
    }
}
